package cn.cdnsu.auth.service.impl;

import cn.cdnsu.auth.domain.Role;
import cn.cdnsu.auth.dto.RoleDTO;
import cn.cdnsu.auth.mapper.RoleMapper;
import cn.cdnsu.auth.service.IRoleServiceI;
import cn.cdnsu.base.service.impl.IBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
@Service
public class RoleServiceImplI extends IBaseServiceImpl<Role> implements IRoleServiceI {

    @Autowired
    private RoleMapper mapper;

    @Transactional
    @Override
    public void insertByRoleId(RoleDTO roleDTO) {
        //删除该角色的权限
        mapper.deleteByRoleId(roleDTO.getId());
        //保存权限
        mapper.inserByRoleId(roleDTO);
    }

    @Override
    public List<String> selectByRoleId(Long id) {
        return mapper.selectByRoleId(id);
    }
}
